Java replaceFirst and replaceAll methods, replacefirst
ReplaceFirst and replaceAll are used to replace the text that matches the regular expression. The difference is that replaceFirst replaces the first match, and replaceAll replaces all matches.
Let's start by outlining their three usage:
replace (charsequence target, charsequence replacement) replaces all target with replacement, and two parameters are strings.
ReplaceAll (string regex, string replacement) replaces all regex matches with
Today, we are using the string replace method to replace the following and. The result shows that it is not easy to use. Then we made a test,
CodeI:
String STR = new string ("and aae112 ");Str. replacefirst ("and ","");System. Out. println (STR );
If not just review the next regular expression, I may also not notice that the original string replaceall and Replacefirst used the regular expression!Not much to explain, look at the code:
1234
Java entry (5) -- String/string class, entry String
In the previous example, there was a String example. Some friends certainly didn't know what to do. In fact, the String class is a special class in Java, namely the String class. It is not one of
1) Initialization of a string objectBecause string objects are particularly common, Java provides a simplified, special syntax for initializing a string object in the following format:String s = "abc";s = "Java language";In fact, according to the
1) Initialization of a string objectBecause string objects are particularly common, Java provides a simplified, special syntax for initializing a string object in the following format:String s = "abc";s = "Java language";In fact, according to the
String description, string
During development, we will frequently use the String class. It is essential to master the implementation and common methods of String. Of course, we also need to understand its internal implementation.I. Implementation of
The version that Scala uses in this article is 2.11.8 17th, type parameter 17.1 generics
generic class
Class Pair[t, S] (Val first:t, Val second:s)
//instantiation
val p = new Pair ("String")
val p2 = new Pair[any, any ] ("String")
Generic
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.